package vn.easyticket.db.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table( name = "E002_EVENT" )
public class E002_Event
extends AbstractEntity
{
    private final boolean DEFAULT_IS_CANCELLED = false;

    @Column( name = "EventId" )
    @Id
    @GeneratedValue( strategy = GenerationType.IDENTITY )
    private Integer eventId;

    @Column( name = "EventName", length = 100, nullable = false, unique = true )
    private String eventName;

    @Column( name = "CreateDate", nullable = false )
    @Temporal( TemporalType.TIMESTAMP )
    private Date createDate;

    @Column( name = "Creator", nullable = false )
    private int creator;

    @Column( name = "StartDate", nullable = false )
    @Temporal( TemporalType.TIMESTAMP )
    private Date startDate;

    @Column( name = "EndDate", nullable = false )
    @Temporal( TemporalType.TIMESTAMP )
    private Date endDate;

    @Column( name = "IsCancelled" )
    private boolean isCancelled = DEFAULT_IS_CANCELLED;

    @Column( name = "CategoryId", nullable = false )
    private int categoryId;

    @Column( name = "EventDetails", nullable = true )
    @Lob
    private String eventDetails;

    public E002_Event()
    {
    }

    public E002_Event( Integer eventId )
    {
        this.eventId = eventId;
    }

    public E002_Event( Integer eventId, String eventName, Date createDate, int creator, Date startDate, Date endDate,
                  boolean isCancelled, int categoryId )
    {
        this.eventId = eventId;
        this.eventName = eventName;
        this.createDate = createDate;
        this.creator = creator;
        this.startDate = startDate;
        this.endDate = endDate;
        this.isCancelled = isCancelled;
        this.categoryId = categoryId;
    }

    public Integer getEventId()
    {
        return eventId;
    }

    public void setEventId( Integer eventId )
    {
        this.eventId = eventId;
    }

    public String getEventName()
    {
        return eventName;
    }

    public void setEventName( String eventName )
    {
        this.eventName = eventName;
    }

    public Date getCreateDate()
    {
        return createDate;
    }

    public void setCreateDate( Date createDate )
    {
        this.createDate = createDate;
    }

    public int getCreator()
    {
        return creator;
    }

    public void setCreator( int creator )
    {
        this.creator = creator;
    }

    public Date getStartDate()
    {
        return startDate;
    }

    public void setStartDate( Date startDate )
    {
        this.startDate = startDate;
    }

    public Date getEndDate()
    {
        return endDate;
    }

    public void setEndDate( Date endDate )
    {
        this.endDate = endDate;
    }

    public boolean getIsCancelled()
    {
        return isCancelled;
    }

    public void setIsCancelled( boolean isCancelled )
    {
        this.isCancelled = isCancelled;
    }

    public int getCategoryId()
    {
        return categoryId;
    }

    public void setCategoryId( int categoryId )
    {
        this.categoryId = categoryId;
    }

    public String getEventDetails()
    {
        return eventDetails;
    }

    public void setEventDetails( String eventDetails )
    {
        this.eventDetails = eventDetails;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += ( eventId != null ? eventId.hashCode() : 0 );
        return hash;
    }

    @Override
    public boolean equals( Object object )
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if ( !( object instanceof E002_Event ) )
        {
            return false;
        }
        E002_Event other = (E002_Event) object;
        if ( ( this.eventId == null && other.eventId != null )
            || ( this.eventId != null && !this.eventId.equals( other.eventId ) ) )
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "Easyticket.dbo.[E002_EVENT][ eventId=" + eventId + " ]";
    }

}
